uniform sampler2DRect tex;
uniform sampler2DRect texOld;

void main(void){
    vec2 uv = gl_TexCoord[0].st;
    vec3 sample;
    vec3 sampleOld;
    
    sample = texture2DRect(tex, ivec2(uv)).rgb;
    float current = length(sample);

    sampleOld = texture2DRect(texOld, ivec2(uv)).rgb;
    float old = length(sampleOld);

    float color = current - old + 0.5;
    
    /*if(color > 0.8)
        color = 1.0;
    else if(color < 0.01)
        color = 0.0;
    else
        color = 0.5;*/

    gl_FragColor = vec4(vec3(color), 1.0);
}
